home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1998 July / EnigmA AMIGA RUN 29 (1998)(G.R. Edizioni)(IT)[!][issue 1998-07 & 08].iso / earcd / ppaint64 / rexx / giftopng.pprx < prev    next >
Text File  |  1996-06-17  |  6KB  |  170 lines

  1. /* PPaint Amiga Rexx script - Copyright © 1995 Cloanto Italia srl */
  2.  
  3. /*
  4.   $VER: GifToPng.pprx 1.0
  5.  
  6.   This script asks the user to specify a directory, scans the directory
  7.   and its subdirectories and converts all GIF files it finds into PNG.
  8.  
  9.   Non-GIF files are not affected. Icon images are preserved. Icon format
  10.   information is updated (Tool Types: FILETYPE=PNG). GIF Author, Copyright
  11.   and Comment fields are translated to PNG equivalents. File name suffixes
  12.   are changed (i.e. the files are renamed) as follows:
  13.  
  14.     .gif   -> .png
  15.     .GIF   -> .PNG
  16.     .Gif   -> .Png, ecc.
  17.  
  18.     others -> unchanged
  19.  
  20.   Personal Paint identifies the file type by its contents (not by the file
  21.   name suffix). If the script runs during Workbench use, the Workbench Update
  22.   menu item must be selected to visually update the contents of any windows
  23.   containing files being renamed by this script.
  24.  
  25.   This script requires Personal Paint version 6.3 (PPaint Rexx version 2)
  26.   or higher, personal_png_io.library (enclosed with PPaint), and
  27.   personal_gif_io.library (available via free electronic distribution).
  28.  
  29.  
  30.   Possible changes that could be applied to this file:
  31.  
  32.     Convert all images to PNG (not just GIFs). To do this, change the line
  33.     selecting GIFs to IF UPPER(RESULT) ~= 'PNG' THEN DO. However, be careful
  34.     if you have IFF animations, as they can be loaded as ILBM images unless
  35.     they are filtered out (IFF animations begin with an ILBM image).
  36.  
  37.     Activate PNG Adam 7 progressive display in files being written. This
  38.     degrades compression but the resulting images appear more nicely when
  39.     displayed by progressive viewers. Set PROGDSP=1.
  40.  
  41.     Convert any file to uncompressed IFF-ILBM. This may be good for files to
  42.     be stored on an Amiga CD-ROM, where loading speed could be more important
  43.     than compression. Remove the instructions selecting only GIFs and replace
  44.     the PNG FORMAT option with FORMAT ILBM OPTIONS "COMPR=0" "SCRFMT=0".
  45.  
  46.  
  47.   PNG was designed as a replacement and extension to GIF and LZW-based TIFF,
  48.   after Unisys Corporation began demanding royalties on GIF/LZW code. As
  49.   the PNG specification was released in May 1995, it gained general
  50.   recognition as the best lossless standard for storing digital images.
  51.  
  52.   Cloanto, the first software house to publish a paint program supporting the
  53.   PNG file format, is also making available a PNG developer's kit for the
  54.   Amiga. This includes instructions for using personal_png_io.library, and is
  55.   a commercial product. A PNG DataType is available at no cost for free
  56.   electronic distribution.
  57.  
  58.   An article on the GIF/LZW issue can be requested by sending E-mail to
  59.  
  60.     <gltext1@cloanto.com>
  61.  
  62.   For more information, or suggestions, please address E-mail to
  63.  
  64.     <info@cloanto.com>
  65.  
  66. */
  67.  
  68.  
  69. MYPORT = 'PPAINT'
  70.  
  71. IF ~SHOW('P', MYPORT) THEN DO
  72.     IF EXISTS('PPaint:PPaint') THEN DO
  73.         ADDRESS COMMAND 'Run >NIL: PPaint:PPaint'
  74.         DO 30 WHILE ~SHOW('P',MYPORT)
  75.              ADDRESS COMMAND 'Wait >NIL: 1 SEC'
  76.         END
  77.     END
  78.     ELSE DO
  79.         SAY "Personal Paint could not be loaded."
  80.         EXIT 10
  81.     END
  82. END
  83.  
  84. IF ~SHOW('P', MYPORT) THEN DO
  85.     SAY 'Personal Paint Rexx port could not be opened.'
  86.     EXIT 10
  87. END
  88.  
  89. ADDRESS VALUE MYPORT
  90. OPTIONS RESULTS
  91. OPTIONS FAILAT 10000
  92.  
  93. Version 'REXX'
  94. IF RESULT < 2 THEN DO
  95.     errmess = 'This script requires a newer_version of Personal Paint.'
  96.     SAY errmess
  97.     RequestNotify 'PROMPT="'errmess'"'
  98.     EXIT 10
  99. END
  100.  
  101. LockGUI
  102. FreeBrush
  103. IF RC = 0 THEN RequestPath '"GifToPng target directory"'
  104. IF RC = 0 THEN DO
  105.     tmpfname = 'T:pprx_temp.'PRAGMA('ID')
  106.     ADDRESS COMMAND 'List >'tmpfname' 'RESULT' NOHEAD PAT=~(#?.info) LFORMAT="*"%s%s*"" ALL FILES'
  107.     IF OPEN('listfile', tmpfname, R) THEN DO
  108.         Get SETTING ICONS
  109.         iconmode = RESULT
  110.         errcode = 0
  111.         Set '"ICONS=3"'
  112.         DO FOREVER
  113.             curfname = READLN('listfile')
  114.             IF EOF('listfile') THEN BREAK
  115.             GetFileFormat curfname
  116.             IF RC = 0 THEN DO
  117.                 IF UPPER(RESULT) = 'GIF' THEN DO
  118.                     SAY 'Processing 'curfname
  119.                     LoadBrush curfname FORCE
  120.                     IF RC = 0 THEN DO
  121.                         IF UPPER(RIGHT(curfname, 5)) = '.GIF"' THEN DO
  122.                             len = LENGTH(curfname)
  123.                             newfname = OVERLAY(D2C(C2D(SUBSTR(curfname, len-3, 1)) + 9), curfname, len-3)
  124.                             newfname = OVERLAY(D2C(C2D(SUBSTR(curfname, len-2, 1)) + 5), newfname, len-2)
  125.                             newfname = OVERLAY(D2C(C2D(SUBSTR(curfname, len-1, 1)) + 1), newfname, len-1)
  126.                             IF EXISTS(SUBSTR(newfname,2,len-2)) = 0 THEN DO
  127.                                 ADDRESS COMMAND 'Rename >NIL: 'curfname' 'newfname
  128.                                 curiconfname = INSERT('.info', curfname, len-1)
  129.                                 newiconfname = INSERT('.info', newfname, len-1)
  130.                                 curfname = newfname
  131.                                 IF EXISTS(SUBSTR(curiconfname,2,len+3)) THEN DO
  132.                                     IF EXISTS(SUBSTR(newiconfname,2,len+3)) THEN
  133.                                         ADDRESS COMMAND 'Delete >NIL: 'curiconfname
  134.                                     ELSE
  135.                                         ADDRESS COMMAND 'Rename >NIL: 'curiconfname' 'newiconfname
  136.                                 END
  137.                             END
  138.                         END
  139.                         SaveBrush 'FORCE FILE 'curfname' FORMAT PNG OPTIONS "PROGDSP=0" "COMPR=6" "AUTO=1"'
  140.                         IF RC > 0 THEN DO
  141.                             errcode = RC
  142.                             IF RC = 5 THEN
  143.                                 errmess = 'User abort during save.'
  144.                             ELSE
  145.                                 errmess = 'Error 'RC' during save.'
  146.                         END
  147.                         FreeBrush FORCE
  148.                     END
  149.                     ELSE DO
  150.                         errcode = RC
  151.                         IF RC = 5 THEN
  152.                             errmess = 'User abort during load.'
  153.                         ELSE
  154.                             errmess = 'Error 'RC' during load.'
  155.                     END
  156.                 END
  157.             END
  158.             IF errcode > 0 THEN BREAK
  159.         END
  160.         IF errcode > 0 THEN DO
  161.             SAY errmess
  162.             RequestNotify 'PROMPT="'errmess'"'
  163.         END
  164.         Set '"ICONS='iconmode'"'
  165.         CALL CLOSE('listfile')
  166.     END
  167.     ADDRESS COMMAND 'Delete >NIL: 'tmpfname
  168. END
  169. UnlockGUI
  170.